#ifndef TIME_WHEEL_H
#define TIME_WHEEL_H

#include "wytimer.h"
#define TW_NODE_NUMS 2
typedef struct _twnode {
	struct timeval expired_time;
	int remainingRounds;
	int repeat;
	timercb* cb;
	void * param;
	struct _twnode* next;
	struct _twnode* prev;
}twnode;

typedef struct _twnode_list {

	twnode* header;
	int len;
}twnode_list;

typedef struct _timewheel {
	twnode_list timer_queue[TW_NODE_NUMS];
	//twnode** timer_queue;
	int critical_times; 
	int current_times;

}timewheel;


typedef struct _timewheel_mgr {

	timewheel wheels1;

}timewheel_mgr;


void init_twnode(twnode* node, int sec, int msec, timercb cb, void * param, int repeat);

void init_timewheel(timewheel* tw, int ct);

int turn_timewheel(timewheel* tw);

void update_timewheel();

void timer_add_timewheel(int sec, int msec, timercb cb, void * param, int repeat);

void add_twnode_list(int idx, twnode* node, int len);

#endif